home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Dec 3, 1996
- //
- // Description:
- // This is a helper script to perform the setKeyframe command
- // using the various options that have been set
- //
- // Input Arguments:
- // int action 0 - just execute the command
- // 1 - show the option box dialog
- // 2 - return the drag command
- //
- // Return Value:
- // None.
- //
-
- proc setOptionVars (int $forceFactorySettings)
- {
- // setKeyframeWhich:
- // 1 : set keyframes on all keyable attrs
- // 2 : set keyframes on all manip handle attrs
- // 3 : set keyframes on current manip handle
- // 4 : set keyframes on all manip handle attrs and all keyable attrs
- //
- if( $forceFactorySettings || !`optionVar -exists setKeyframeWhich` ) {
- optionVar -intValue setKeyframeWhich 4;
- }
-
- if( $forceFactorySettings || !`optionVar -exists setKeyframePrompt` ) {
- optionVar -intValue setKeyframePrompt 0;
- }
-
- if ( $forceFactorySettings || !`optionVar -exists keySetIKFK` ) {
- optionVar -intValue keySetIKFK 0;
- }
-
- if( $forceFactorySettings || !`optionVar -exists keyHierarchy`) {
- optionVar -intValue keyHierarchy 0;
- }
- // use channel box attrs
- //
- if ($forceFactorySettings || !`optionVar -exists keyUseChannelBox`) {
- optionVar -intValue keyUseChannelBox 0;
- }
- // -controlPoints
- //
- if ($forceFactorySettings || !`optionVar -exists keyControlPoints`) {
- optionVar -intValue keyControlPoints 0;
- }
- // -shape
- //
- if ($forceFactorySettings || !`optionVar -exists keyShapes`) {
- optionVar -intValue keyShapes 1;
- }
- }
-
- global proc setKeyframeSetup (string $parent, int $forceFactorySettings)
- {
- // Retrieve the option settings
- //
- setOptionVars( $forceFactorySettings );
-
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls
- //
- int $whichAttrs = `optionVar -query setKeyframeWhich`;
- switch($whichAttrs)
- {
- case 1:
- radioButtonGrp -edit -sl 1 allAttrsRB;
- break;
- case 2:
- radioButtonGrp -edit -sl 1 allManipAttrsRB;
- break;
- case 3:
- radioButtonGrp -edit -sl 1 curManipHandleRB;
- break;
- case 4:
- radioButtonGrp -edit -sl 1 allManipOrAttrsRB;
- break;
- }
-
- if( `optionVar -query setKeyframePrompt` == 1 ) {
- radioButtonGrp -e -select 2 setKeyframePrompt;
- } else {
- radioButtonGrp -e -select 1 setKeyframePrompt;
- }
-
- checkBoxGrp -edit -value1 `optionVar -query keySetIKFK` setIKFKCB;
-
- if (`optionVar -query keyHierarchy` == 1) {
- radioButtonGrp -edit -select 2 hierarchyRB;
- } else {
- radioButtonGrp -edit -select 1 hierarchyRB;
- }
-
- if (`optionVar -query keyUseChannelBox` == 1) {
- radioButtonGrp -edit -select 2 channelsRB;
- } else {
- radioButtonGrp -edit -select 1 channelsRB;
- }
-
- checkBoxGrp -edit -value1 `optionVar -query keyControlPoints` controlCB;
- checkBoxGrp -edit -value1 `optionVar -query keyShapes` shapesCB;
-
- keyEnabling $parent ($whichAttrs == 1);
- }
-
- global proc setKeyframeCallback (string $parent, int $doIt, string $selectionConnection)
- //
- // Description:
- // Set the optionVar's from the control values, and then perform
- // the command
- //
- {
- setParent $parent;
-
- if( `radioButtonGrp -q -sl allManipAttrsRB` == 1) {
- optionVar -intValue setKeyframeWhich 2;
- } else if( `radioButtonGrp -q -sl curManipHandleRB` == 1 ) {
- optionVar -intValue setKeyframeWhich 3;
- } else if( `radioButtonGrp -q -sl allAttrsRB` == 1 ) {
- optionVar -intValue setKeyframeWhich 1;
- } else {
- optionVar -intValue setKeyframeWhich 4;
- }
-
- if (`radioButtonGrp -query -select setKeyframePrompt` == 2) {
- optionVar -intValue setKeyframePrompt 1;
- } else {
- optionVar -intValue setKeyframePrompt 0;
- }
-
- optionVar -intValue keySetIKFK `checkBoxGrp -query -value1 setIKFKCB`;
-
- if (`radioButtonGrp -query -select hierarchyRB` == 2) {
- optionVar -intValue keyHierarchy 1;
- } else {
- optionVar -intValue keyHierarchy 0;
- }
-
- if (`radioButtonGrp -query -select channelsRB` == 2) {
- optionVar -intValue keyUseChannelBox 1;
- } else {
- optionVar -intValue keyUseChannelBox 0;
- }
-
- optionVar -intValue keyControlPoints
- `checkBoxGrp -query -value1 controlCB`;
- optionVar -intValue keyShapes
- `checkBoxGrp -query -value1 shapesCB`;
-
- if ($doIt)
- {
- string $args[] = {(string)
- 0,
- $selectionConnection
- };
-
- performSetKeyframeArgList 1 $args;
- string $tmpCmd = "performSetKeyframeArgList 1 " + "{ \"0\", ";
- $tmpCmd += "\"" + $selectionConnection + "\"}";
- addToRecentCommandQueue $tmpCmd "SetKeyframe";
- }
- }
-
-
- global proc keyEnabling(string $parent, int $state)
- {
- setParent $parent;
-
- radioButtonGrp -edit -enable $state hierarchyRB;
- radioButtonGrp -edit -enable $state channelsRB;
-
- keyChannelsEnabling $parent
- ($state && (`radioButtonGrp -query -select channelsRB` == 1));
- }
-
- global proc keyChannelsEnabling(string $parent, int $state)
- {
- setParent $parent;
-
- checkBoxGrp -edit -enable $state controlCB;
- checkBoxGrp -edit -enable $state shapesCB;
- }
-
- global proc keyIKFKEnabling(string $parent, int $state)
- {
- setParent $parent;
- checkBoxGrp -edit -enable $state setIKFKCB;
- }
-
- proc string setKeyframeWidgets( string $parent )
- {
- setParent $parent;
-
- string $tabForm = `columnLayout -adjustableColumn true`;
-
- // Make a collection of 4 radio groups instead of one with 4 options,
- // so that we can line up the text on separate lines
- //
- radioButtonGrp -numberOfRadioButtons 1
- -cw2 170 400
- -label "Set Keys on"
- -label1 "All Manipulator Handles and Keyable Attributes"
- allManipOrAttrsRB;
-
- radioButtonGrp -numberOfRadioButtons 1
- -cw2 170 400
- -label1 "All Keyable Attributes"
- -cc ("keyEnabling "+ $parent+" #1")
- -shareCollection allManipOrAttrsRB
- allAttrsRB;
-
- radioButtonGrp -numberOfRadioButtons 1
- -cw2 170 400
- -label1 "All Manipulator Handles"
- -shareCollection allManipOrAttrsRB
- allManipAttrsRB;
-
- radioButtonGrp -numberOfRadioButtons 1
- -cw2 170 400
- -label1 "Current Manipulator Handle"
- -shareCollection allManipOrAttrsRB
- curManipHandleRB;
-
- radioButtonGrp -numberOfRadioButtons 2
- -cw3 170 160 200
- -label "Set Keys at"
- -label1 "Current Time"
- -label2 "Prompt"
- -cc1 ("keyIKFKEnabling "+ $parent+" #1")
- setKeyframePrompt;
-
- checkBoxGrp -label "Set IK/FK Keys" -ncb 1 -label1 "" setIKFKCB;
-
- separator -style "in";
-
- radioButtonGrp -numberOfRadioButtons 2
- -cw3 170 160 200
- -label Hierarchy -label1 "Selected" -label2 "Below"
- hierarchyRB;
-
- radioButtonGrp -numberOfRadioButtons 2 -label "Channels"
- -cw3 170 160 200
- -label1 "All Keyable"
- -label2 "From Channel Box"
- -cc1 ("keyChannelsEnabling " + $parent + " #1")
- channelsRB;
-
- checkBoxGrp -label "Control Points" -ncb 1 -label1 "" controlCB;
- checkBoxGrp -label "Shapes" -ncb 1 -label1 "" shapesCB;
-
- return $tabForm;
- }
-
- global proc setKeyframeOptions (string $selectionConnection)
- {
- string $commandName = "setKeyframe";
-
- string $applyTitle = "Set Key";
-
- // Build the option box "methods"
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // Get the option box.
- //
- // The value returned is the name of the layout to be used as
- // the parent for the option box UI.
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- setOptionBoxCommandName($commandName);
-
- setUITemplate -pushTemplate DefaultTemplate;
- waitCursor -state 1;
- tabLayout -scr true -tv false; // To get the scroll bars
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- setKeyframeWidgets $parent;
-
- waitCursor -state 0;
- setUITemplate -popTemplate;
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit
- -label $applyTitle
- -command ($callback + " " + $parent + " " + 1 + " \"" + $selectionConnection + "\"")
- $applyBtn;
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + " \"" + $selectionConnection + "\"; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1)
- $resetBtn;
-
- // Set the option box title.
- //
- setOptionBoxTitle("Set Key Options");
-
- // Customize the 'Help' menu item text.
- //
- setOptionBoxHelpTag( "SetKey" );
-
- // Set the current values of the option box.
- //
- eval (($setup + " " + $parent + " " + 0));
-
- // Show the option box.
- //
- showOptionBox();
- }
-
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc string assembleCmd (string $selectionConnection)
- {
- string $cmd;
-
- setOptionVars(false);
-
- // doSetKeyframeArgList takes a string array
- //
- $cmd = "doSetKeyframeArgList 4 { " +
- "\"" + `optionVar -query setKeyframeWhich` + "\"" +
- ",\"" + `optionVar -query keyHierarchy` + "\"" +
- ",\"" + `optionVar -query keyUseChannelBox` + "\"" +
- ",\"" + `optionVar -query keyControlPoints` + "\"" +
- ",\"" + `optionVar -query keyShapes` + "\"" +
- ",\"" + `optionVar -query setKeyframePrompt` + "\"" +
- ",\"" + false + "\"" +
- ",\"" + $selectionConnection + "\"" +
- ",\"" + `optionVar -query keySetIKFK` + "\"" +
- " };";
-
- return $cmd;
- }
-
- global proc string
- performSetKeyframeArgList (string $version, string $args[])
- //
- // Input Arguments:
- // $version: The version of this option box. Used to know how to
- // interpret the $args array.
- // "1" : $action, $selectionConnection
- //
- // $args
- // Version 1
- // [0] $action 0 - do the command
- // 1 - show the option box
- // 2 - return the drag command
- // [1] $selectionConnection name of selection connection to use
- //
- // Return Value:
- // The actual command to execute.
- //
- {
- int $versionNum = $version;
-
- int $action = $args[0];
- string $selectionConnection = $args[1];
-
- string $cmd = "";
-
- switch ($action) {
-
- // Execute the command.
- //
- case 0:
- // Retrieve the option settings
- //
- setOptionVars(false);
-
- // Get the command.
- //
- $cmd = assembleCmd ($selectionConnection);
-
- // Execute the command with the option settings.
- //
- eval($cmd);
-
- break;
-
- // Show the option box.
- //
- case 1:
- setKeyframeOptions ($selectionConnection);
- break;
-
- // Return the command string.
- //
- case 2:
- // Retrieve the option settings.
- //
- setOptionVars (false);
-
- // Get the command.
- //
- $cmd = assembleCmd ($selectionConnection);
- break;
- }
- return $cmd;
- }
-